using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerStats : CharacterStats
{
    private Player player;

    protected override void Start()
    {
        base.Start();
        player = GetComponent<Player>();
    }

    public override void TakeDamage(int damage)
    {
        base.TakeDamage(damage);
        
    }

    protected override void Die()
    {
        base.Die();

        player.Die();
    }

    protected override void DectreaseHealthBy(int damage)
    {
        base.DectreaseHealthBy(damage);

        Inventory.instance.GetEquipment(EquipmentType.Armor)?.Effect(player.transform);

    }

    public override void OnEvasion()
    {
        base.OnEvasion();
        player.skill.doage.CreateMirageOnDodge();
    }

    public void CloneDoDamage(CharacterStats targetStats,float multiplier)
    {
        if (TargetCanAvoidAttack(targetStats)) return;

        targetStats.GetComponent<Entity>().SetupKnockbackDir(transform);


        int totalDmage = damage.GetValue() - strength.GetValue();

        if (multiplier>0)
        {
            totalDmage = Mathf.RoundToInt(totalDmage * multiplier);
        }

        totalDmage = CheckTargetArmor(targetStats, totalDmage);

        if (CanCrit())
        {
            totalDmage = CalculateCriticalDamage(totalDmage);
        }

        targetStats.TakeDamage(totalDmage);
    }
}
